/**************************************************************************
 *         Copyright(c) 2007 by Sunplus mMedia  Technology Co., Ltd.       *
 *                                                                         *
 *  This software is copyrighted by and is the property of Sunplus mMedia  *
 *  Technology Co., Ltd. All rights are reserved by Sunplus mMedia Techno- *
 *  logy Co., Ltd. This software may only be used in accordance with the   *
 *  corresponding license agreement. Any unauthorized use, duplication,    *
 *  distribution, or disclosure of this software is expressly forbidden.   *
 *                                                                         *
 *  This Copyright notice "M U S T" not be removed or modified without     *
 *  prior written consent of Sunplus mMedia Technology  Co., Ltd.          *
 *                                                                         *
 *  Sunplus mMedia Technology Co., Ltd. reserves the right to modify this  *
 *  software without notice.                                               *
 *                                                                         *
 *  Sunplus mMedia Technology Co., Ltd.                                    *
 *  19-1, Innovation First Road, Science-Based Industrial Park,            *
 *  Hsin-Chu, Taiwan, R.O.C.                                               *
 *                                                                         *
 **************************************************************************/
/**
 * @file		app_ui_para.c
 * @brief		App for UI setting parameter
 * @author	Phil Lin
 * @since		2008-02-20
 * @date		2008-02-20
 */
 
#include "general.h"
#include "initio.h"
#include "sp1k_rsvblk_api.h"
#include "app_ui_para.h"
#include "app_menu_micro.h"

/**************************************************************************
 *                           C O N S T A N T S                            *
 **************************************************************************/
 
/*Don't modify this value!*/
#define UI_PARAM_SIZE		512

/**************************************************************************
 *                              M A C R O S                               *
 **************************************************************************/

/**************************************************************************
 *                          D A T A    T Y P E S                          *
 **************************************************************************/
/*static uiPara_t xdata sPara _at_ 0x7000;*/

static UINT8 xdata uiPara[UI_PARAM_SIZE] _at_ 0x7000;
static uiPara_t xdata * xdata psPara;

/**************************************************************************
 *                         G L O B A L    D A T A                         *
 **************************************************************************/
extern UINT8 appUDFLoad(void);

/**************************************************************************
 *                 E X T E R N A L    R E F E R E N C E S                 *
 **************************************************************************/

//-----------------------------------------------------------------------------
//appUiParaInit
//-----------------------------------------------------------------------------
/**
 * @brief		UI parameter initio
 * @param	mode:init mode
 * @retval	NULL
 * @see
 * @author	Phil Lin
 * @since		2008-02-20
 * @todo		Something need to be done.
 * @bug		a bug need to be resolved.
*/
void appUiParaInit(uiParaInitMode_t mode) USING_0
{
	UINT32 freeBuffAddr = K_SDRAM_ImagePlaybackBufAddr;
	UINT8 resID;

	if (mode == PARA_INIT_FROM_UDF) {
		//Load UDF from nand reserve block
		psPara = (uiPara_t*)&uiPara[0];

		psPara->EmptyPara = 0;
		if(appUDFLoad()==SUCCESS)
		{
			psPara->DriverMode = PRV_SNAP_SINGLE;
			psPara->ImageEffect=PRV_EFFECT_NORNAL;
			//psPara->WBMode = PRV_WB_AUTO;
			psPara->AEMode = PRV_COMP_0EV;
/* ------ Note: Demo code zone start flag, don't modify or delete this line!!! ------ */
#if PHOTO_FRAME_PV
			psPara->PhotoFrame = PRV_PHOTO_FRAME_OFF;
#endif
/* ------ Note: Demo code zone end flag, don't modify or delete this line!!! ------ */
			//psPara->SleepTime = POWER_SAVE_5MIN;	//mark for mantis #36863

			if (prjDbgMode) {
				psPara->USBMode = USB_PCCAM;
			} else {
				psPara->USBMode = USB_MASS;
			}
			return;
		}
	} 
	psPara = (uiPara_t*)&uiPara[0];

	psPara->EmptyPara = 0;
	psPara->DriverMode = PRV_SNAP_SINGLE;
	psPara->ImageSize = PRV_SIZE_3M;
	psPara->ImageQuality = PRV_QUAL_FINE;
	psPara->WBMode = PRV_WB_AUTO;
	psPara->AEMetering	= PRV_METER_MULTI;
	psPara->AEMode = PRV_COMP_0EV;
/* ------ Note: Demo code zone start flag, don't modify or delete this line!!! ------ */
#if PHOTO_FRAME_PV
	psPara->PhotoFrame = PRV_PHOTO_FRAME_OFF;
#endif	
/* ------ Note: Demo code zone end flag, don't modify or delete this line!!! ------ */
	psPara->ImageEffect = PRV_EFFECT_NORNAL;
	psPara->VideoSize = MOV_SIZE_D1;
	psPara->FrameRate = MOV_FRM_HIGH;

	psPara->OpenPic = PB_OPENPIC_DEFAULT;
	psPara->Language = ENGLISH;
	psPara->StampMode = PRV_STAMP_OFF;
	
	if (prjDbgMode) {
		psPara->USBMode = USB_PCCAM;
	} else {
		psPara->USBMode = USB_MASS;
	}

	//psPara->SleepTime = POWER_SAVE_3MIN;
	psPara->TVMode = TVMODE_NTSC;
	psPara->BeepSound = BEEP_ON;
	psPara->ShutterSound = SHUTTER_ON;
	psPara->Language = ENGLISH;

	psPara->Volume=VOLUME_2;
	psPara->StartupSound=STARTSOUND_1;
	psPara->LightFreq=PRV_FREQ_50;
	psPara->StartupImage = PB_OPENPIC_DEFAULT;
	psPara->AutoReviewTime=QUICKVIEW_1S;
	psPara->SleepTime=POWER_SAVE_1MIN;
	psPara->SunplusFlag[0]='D';//'S';//zhenglei
	psPara->SunplusFlag[1]='C';//'U';
	psPara->SunplusFlag[2]='I';//'N';
	psPara->SunplusFlag[3]='M';//'P';

	resID = 0x0d; //.\a\open.jpg
	sp1kNandRsvRead(resID, freeBuffAddr << 1);
	resID = 0x81; //.\b\open.jpg
	sp1kNandRsvWrite(resID, freeBuffAddr << 1);
}

//-----------------------------------------------------------------------------
//appUiParaGet
//-----------------------------------------------------------------------------
/**
 * @brief		Get ui parameter pointer
 * @param	NULL
 * @retval	ui parameter pointer
 * @see
 * @author	Phil Lin
 * @since		2008-02-20
 * @todo		Something need to be done.
 * @bug		a bug need to be resolved.
*/
uiPara_t* appUiParaGet(void)
{
	return psPara;
}
